<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/public/base.jspf"%>
<body>
	<form id="addOrUpdate" method="post">
		<hidden id="hidden-params">
			<input id="btn_sub" type="hidden" onclick="submitForm()"/>
			<input id="goods_type_ids" name="goodsTypeIds" value="${m.goodsTypeIds}" type="hidden"/>
		</hidden>
		<div>   
	        <label for="type_tree_menu">上级类别:</label>
	        <input id="type_tree_menu" />   
	    </div>
	    <div>   
	        <label for="text">类别名称:</label>
	        <input type="text" id="text" name="text" value="${m.text}" class="easyui-validatebox easyui-textbox" data-options="required:true"/>   
	    </div>
	    <div>
        	<label for="level" class="ui-label">LOGO:</label>
        	<input id="logo" type="text" style="width:300px">
        </div>
	</form>
	<script type="text/javascript">
		var id = '${m.id}';
		//如果不为空，表示修改操作
		if(id!='' && id!=undefined){
			$('#hidden-params').append('<input name="id" value="${m.id}" type="hidden" />');
			$('#hidden-params').append('<input name="_method" value="put" type="hidden"/>');
		}

		$('#type_tree_menu').combotree({
		    url: '${xpath}/goodsType/pageList',
		    required: true,//是否必选
		    multiple:true,//是否支持多选
		    panelWidth:230,
		    loadFilter:function(data){
	        	return data.obj;
	        },
	        onLoadSuccess:function(row,data){
	        	var goodsTypeIds = '${m.goodsTypeIds}';
	        	if(goodsTypeIds!='' && goodsTypeIds!=undefined){
	        		$('#type_tree_menu').combotree('setValues',goodsTypeIds);
	        	}
	        }
		});
		//文件选择框
		$('#logo').filebox({
		    buttonText: '选择文件',
		    width: 230
		});
		function submitForm(){
			$('#addOrUpdate').form('submit', {
			    url:'manage',
			    onSubmit: function(params){
			    	//获取上级菜单ID
			    	var ids = $('#type_tree_menu').combotree('getValues');//.tree('getSelected');	// 获取树对象选择的节点
			    	$('#goods_type_ids').val(ids.join(','));
			        return $(this).form('validate');
			    },
			    success:function(data){
			    	var info = eval('('+data+')');
			    	if(info.success){
				    	$(this).parent().dialog('destroy');
				    	$('#datagrid_list').treegrid('reload');	// 重新载入所有行
			    	}else{
				    	$.messager.alert('消息',info.msg);
			    	}
			    }
			});  
		}
	</script>
</body>